<?php
define("EW_PAGE_ID", "edit", TRUE); // Page ID
define("EW_TABLE_NAME", 'subcat', TRUE);
?>
<?php 
session_start(); // Initialize session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg50.php" ?>
<?php include "ewmysql50.php" ?>
<?php include "phpfn50.php" ?>
<?php include "subcatinfo.php" ?>
<?php include "userfn50.php" ?>
<?php include "usersinfo.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Open connection to the database
$conn = ew_Connect();
?>
<?php
$Security = new cAdvancedSecurity();
?>
<?php
if (!$Security->IsLoggedIn()) $Security->AutoLogin();
$Security->LoadCurrentUserLevel('subcat');
if (!$Security->IsLoggedIn()) {
	$Security->SaveLastUrl();
	Page_Terminate("login.php");
}
if (!$Security->CanEdit()) {
	$Security->SaveLastUrl();
	Page_Terminate("subcatlist.php");
}
?>
<?php

// Common page loading event (in userfn*.php)
Page_Loading();
?>
<?php

// Page load event, used in current page
Page_Load();
?>
<?php
$subcat->Export = @$_GET["export"]; // Get export parameter
$sExport = $subcat->Export; // Get export parameter, used in header
$sExportFile = $subcat->TableVar; // Get export file, used in header
?>
<?php

// Load key from QueryString
if (@$_GET["sub_id"] <> "") {
	$subcat->sub_id->setQueryStringValue($_GET["sub_id"]);
}

// Create form object
$objForm = new cFormObj();
if (@$_POST["a_edit"] <> "") {
	$subcat->CurrentAction = $_POST["a_edit"]; // Get action code
	GetUploadFiles(); // Get upload files
	LoadFormValues(); // Get form values
} else {
	$subcat->CurrentAction = "I"; // Default action is display
}

// Check if valid key
if ($subcat->sub_id->CurrentValue == "") Page_Terminate($subcat->getReturnUrl()); // Invalid key, exit
switch ($subcat->CurrentAction) {
	case "I": // Get a record to display
		if (!LoadRow()) { // Load Record based on key
			$_SESSION[EW_SESSION_MESSAGE] = "No records found"; // No record found
			Page_Terminate($subcat->getReturnUrl()); // Return to caller
		}
		break;
	Case "U": // Update
		$subcat->SendEmail = TRUE; // Send email on update success
		if (EditRow()) { // Update Record based on key
			$_SESSION[EW_SESSION_MESSAGE] = "Update successful"; // Update success
			Page_Terminate($subcat->getReturnUrl()); // Return to caller
		} else {
			RestoreFormValues(); // Restore form values if update failed
		}
}

// Render the record
$subcat->RowType = EW_ROWTYPE_EDIT; // Render as edit
RenderRow();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--
var EW_PAGE_ID = "edit"; // Page id

//-->
</script>
<script type="text/javascript">
<!--

function ew_ValidateForm(fobj) {
	if (fobj.a_confirm && fobj.a_confirm.value == "F")
		return true;
	var i, elm, aelm, infix;
	var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
	for (i=0; i<rowcnt; i++) {
		infix = (fobj.key_count) ? String(i+1) : "";
		elm = fobj.elements["x" + infix + "_parent_id"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - Parent ID"))
				return false;
		}
		elm = fobj.elements["x" + infix + "_sub_order"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - Order"))
				return false;
		}
		elm = fobj.elements["x" + infix + "_sub_order"];
		if (elm && !ew_CheckInteger(elm.value)) {
			if (!ew_OnError(elm, "Incorrect integer - Order"))
				return false; 
		}
		elm = fobj.elements["x" + infix + "_sub_type"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - Type"))
				return false;
		}
		elm = fobj.elements["x" + infix + "_sub_link"];
		if (elm && !ew_CheckFileType(elm.value)) { 
			if (!ew_OnError(elm, "File type is not allowed.")) 
				return false; 
		}
	}
	return true;
}

//-->
</script>
<script type="text/javascript">
<!--
var ew_DHTMLEditors = [];

//-->
</script>
<script type="text/javascript">
<!--
var ew_MultiPagePage = "Page"; // multi-page Page Text
var ew_MultiPageOf = "of"; // multi-page Of Text
var ew_MultiPagePrev = "Prev"; // multi-page Prev Text
var ew_MultiPageNext = "Next"; // multi-page Next Text

//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->

</script>
<p><span class="phpmaker">Edit TABLE: subcat<br><br><a href="<?php echo $subcat->getReturnUrl() ?>">Go Back</a></span></p>
<?php
if (@$_SESSION[EW_SESSION_MESSAGE] <> "") {
?>
<p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
<?php
	$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message
}
?>
<form name="fsubcatedit" id="fsubcatedit" action="subcatedit.php" method="post" enctype="multipart/form-data" onSubmit="return ew_ValidateForm(this);">
<p>
<input type="hidden" name="a_edit" id="a_edit" value="U">
<table class="ewTable">
	<tr class="ewTableRow">
		<td class="ewTableHeader">Sub ID</td>
		<td<?php echo $subcat->sub_id->CellAttributes() ?>><span id="cb_x_sub_id">
<div<?php echo $subcat->sub_id->ViewAttributes() ?>><?php echo $subcat->sub_id->EditValue ?></div>
<input type="hidden" name="x_sub_id" id="x_sub_id" value="<?php echo ew_HtmlEncode($subcat->sub_id->CurrentValue) ?>">
</span></td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="ewTableHeader">Parent ID<span class='ewmsg'>&nbsp;*</span></td>
		<td<?php echo $subcat->parent_id->CellAttributes() ?>><span id="cb_x_parent_id">
<select id="x_parent_id" name="x_parent_id"<?php echo $subcat->parent_id->EditAttributes() ?>>
<!--option value="">Please Select</option-->
<?php
if (is_array($subcat->parent_id->EditValue)) {
	$arwrk = $subcat->parent_id->EditValue;
	$rowswrk = count($arwrk);
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($subcat->parent_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected" : "";	
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
			}
}
?>
</select>
</span></td>
	</tr>
	<tr class="ewTableRow">
		<td class="ewTableHeader">Name</td>
		<td<?php echo $subcat->sub_name->CellAttributes() ?>><span id="cb_x_sub_name">
<input type="text" name="x_sub_name" id="x_sub_name"  size="30" maxlength="250" value="<?php echo $subcat->sub_name->EditValue ?>"<?php echo $subcat->sub_name->EditAttributes() ?>>
</span></td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="ewTableHeader">Order<span class='ewmsg'>&nbsp;*</span></td>
		<td<?php echo $subcat->sub_order->CellAttributes() ?>><span id="cb_x_sub_order">
<input type="text" name="x_sub_order" id="x_sub_order"  size="30" value="<?php echo $subcat->sub_order->EditValue ?>"<?php echo $subcat->sub_order->EditAttributes() ?>>
</span></td>
	</tr>
	<tr class="ewTableRow">
		<td class="ewTableHeader">Type<span class='ewmsg'>&nbsp;*</span></td>
		<td<?php echo $subcat->sub_type->CellAttributes() ?>><span id="cb_x_sub_type">
<?php
$arwrk = $subcat->sub_type->EditValue;
if (is_array($arwrk)) {
	$rowswrk = count($arwrk);
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($subcat->sub_type->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " checked" : "";
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<input type="radio" name="x_sub_type" id="x_sub_type" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $subcat->sub_type->EditAttributes() ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
	}
}
?>
</span></td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="ewTableHeader">Link</td>
		<td<?php echo $subcat->sub_link->CellAttributes() ?>><span id="cb_x_sub_link">
<?php if (!is_null($subcat->sub_link->Upload->DbValue)) { ?>
<input type="radio" name="a_sub_link" id="a_sub_link" value="1" checked>Keep&nbsp;
<input type="radio" name="a_sub_link" id="a_sub_link" value="2">Remove&nbsp;
<input type="radio" name="a_sub_link" id="a_sub_link" value="3">Replace<br>
<?php } else { ?>
<input type="hidden" name="a_sub_link" id="a_sub_link" value="3">
<?php } ?>
<input type="file" name="x_sub_link" id="x_sub_link"  size="30" onchange="if (this.form.a_sub_link[2]) this.form.a_sub_link[2].checked=true;"<?php echo $subcat->sub_link->EditAttributes() ?>>
</span></td>
	</tr>
	<tr class="ewTableRow">
		<td class="ewTableHeader">Home Page</td>
		<td<?php echo $subcat->sub_homepage->CellAttributes() ?>><span id="cb_x_sub_homepage">
<?php
$arwrk = $subcat->sub_homepage->EditValue;
if (is_array($arwrk)) {
	$armultiwrk= explode(",", strval($subcat->sub_homepage->CurrentValue));
	$rowswrk = count($arwrk);
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = "";
		for ($ari = 0; $ari < count($armultiwrk); $ari++) {
			if (strval($arwrk[$rowcntwrk][0]) == trim(strval($armultiwrk[$ari]))) {
				$selwrk = " checked";
				break;
			}
		}
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<input type="checkbox" name="x_sub_homepage[]" id="x_sub_homepage[]" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $subcat->sub_homepage->EditAttributes() ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
	}
}
?>
</span></td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="ewTableHeader">Active</td>
		<td<?php echo $subcat->sub_active->CellAttributes() ?>><span id="cb_x_sub_active">
<?php
$arwrk = $subcat->sub_active->EditValue;
if (is_array($arwrk)) {
	$armultiwrk= explode(",", strval($subcat->sub_active->CurrentValue));
	$rowswrk = count($arwrk);
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = "";
		for ($ari = 0; $ari < count($armultiwrk); $ari++) {
			if (strval($arwrk[$rowcntwrk][0]) == trim(strval($armultiwrk[$ari]))) {
				$selwrk = " checked";
				break;
			}
		}
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<input type="checkbox" name="x_sub_active[]" id="x_sub_active[]" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $subcat->sub_active->EditAttributes() ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
	}
}
?>
</span></td>
	</tr>
</table>
<p>
<input type="submit" name="btnAction" id="btnAction" value="   Edit   ">
</form>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php include "footer.php" ?>
<?php

// If control is passed here, simply terminate the page without redirect
Page_Terminate();

// -----------------------------------------------------------------
//  Subroutine Page_Terminate
//  - called when exit page
//  - clean up connection and objects
//  - if url specified, redirect to url, otherwise end response
function Page_Terminate($url = "") {
	global $conn;

	// Page unload event, used in current page
	Page_Unload();

	// Global page unloaded event (in userfn*.php)
	Page_Unloaded();

	 // Close Connection
	$conn->Close();

	// Go to url if specified
	if ($url <> "") {
		ob_end_clean();
		header("Location: $url");
	}
	exit();
}
?>
<?php

// Function Get upload files
function GetUploadFiles() {
	global $objForm, $subcat;

	// Get upload data
		if ($subcat->sub_link->Upload->UploadFile()) {

			// No action required
		} else {
			echo $subcat->sub_link->Upload->Message;
			exit();
		}
}
?>
<?php

// Load form values
function LoadFormValues() {

	// Load from form
	global $objForm, $subcat;
	$subcat->sub_id->setFormValue($objForm->GetValue("x_sub_id"));
	$subcat->parent_id->setFormValue($objForm->GetValue("x_parent_id"));
	$subcat->sub_name->setFormValue($objForm->GetValue("x_sub_name"));
	$subcat->sub_order->setFormValue($objForm->GetValue("x_sub_order"));
	$subcat->sub_type->setFormValue($objForm->GetValue("x_sub_type"));
	$subcat->sub_homepage->setFormValue($objForm->GetValue("x_sub_homepage"));
	$subcat->sub_active->setFormValue($objForm->GetValue("x_sub_active"));
}

// Restore form values
function RestoreFormValues() {
	global $subcat;
	$subcat->sub_id->CurrentValue = $subcat->sub_id->FormValue;
	$subcat->parent_id->CurrentValue = $subcat->parent_id->FormValue;
	$subcat->sub_name->CurrentValue = $subcat->sub_name->FormValue;
	$subcat->sub_order->CurrentValue = $subcat->sub_order->FormValue;
	$subcat->sub_type->CurrentValue = $subcat->sub_type->FormValue;
	$subcat->sub_homepage->CurrentValue = $subcat->sub_homepage->FormValue;
	$subcat->sub_active->CurrentValue = $subcat->sub_active->FormValue;
}
?>
<?php

// Load row based on key values
function LoadRow() {
	global $conn, $Security, $subcat;
	$sFilter = $subcat->SqlKeyFilter();
	if (!is_numeric($subcat->sub_id->CurrentValue)) {
		return FALSE; // Invalid key, exit
	}
	$sFilter = str_replace("@sub_id@", ew_AdjustSql($subcat->sub_id->CurrentValue), $sFilter); // Replace key value

	// Call Row Selecting event
	$subcat->Row_Selecting($sFilter);

	// Load sql based on filter
	$subcat->CurrentFilter = $sFilter;
	$sSql = $subcat->SQL();
	if ($rs = $conn->Execute($sSql)) {
		if ($rs->EOF) {
			$LoadRow = FALSE;
		} else {
			$LoadRow = TRUE;
			$rs->MoveFirst();
			LoadRowValues($rs); // Load row values

			// Call Row Selected event
			$subcat->Row_Selected($rs);
		}
		$rs->Close();
	} else {
		$LoadRow = FALSE;
	}
	return $LoadRow;
}

// Load row values from recordset
function LoadRowValues(&$rs) {
	global $subcat;
	$subcat->sub_id->setDbValue($rs->fields('sub_id'));
	$subcat->parent_id->setDbValue($rs->fields('parent_id'));
	$subcat->sub_name->setDbValue($rs->fields('sub_name'));
	$subcat->sub_order->setDbValue($rs->fields('sub_order'));
	$subcat->sub_type->setDbValue($rs->fields('sub_type'));
	$subcat->sub_link->Upload->DbValue = $rs->fields('sub_link');
	$subcat->sub_homepage->setDbValue($rs->fields('sub_homepage'));
	$subcat->sub_active->setDbValue($rs->fields('sub_active'));
}
?>
<?php

// Render row values based on field settings
function RenderRow() {
	global $conn, $Security, $subcat;

	// Call Row Rendering event
	$subcat->Row_Rendering();

	// Common render codes for all row types
	// sub_id

	$subcat->sub_id->CellCssStyle = "";
	$subcat->sub_id->CellCssClass = "";

	// parent_id
	$subcat->parent_id->CellCssStyle = "";
	$subcat->parent_id->CellCssClass = "";

	// sub_name
	$subcat->sub_name->CellCssStyle = "";
	$subcat->sub_name->CellCssClass = "";

	// sub_order
	$subcat->sub_order->CellCssStyle = "";
	$subcat->sub_order->CellCssClass = "";

	// sub_type
	$subcat->sub_type->CellCssStyle = "";
	$subcat->sub_type->CellCssClass = "";

	// sub_link
	$subcat->sub_link->CellCssStyle = "";
	$subcat->sub_link->CellCssClass = "";

	// sub_homepage
	$subcat->sub_homepage->CellCssStyle = "";
	$subcat->sub_homepage->CellCssClass = "";

	// sub_active
	$subcat->sub_active->CellCssStyle = "";
	$subcat->sub_active->CellCssClass = "";
	if ($subcat->RowType == EW_ROWTYPE_VIEW) { // View row
	} elseif ($subcat->RowType == EW_ROWTYPE_ADD) { // Add row
	} elseif ($subcat->RowType == EW_ROWTYPE_EDIT) { // Edit row

		// sub_id
		$subcat->sub_id->EditCustomAttributes = "";
		$subcat->sub_id->EditValue = $subcat->sub_id->CurrentValue;
		$subcat->sub_id->CssStyle = "";
		$subcat->sub_id->CssClass = "";
		$subcat->sub_id->ViewCustomAttributes = "";

		// parent_id
		$subcat->parent_id->EditCustomAttributes = "";
		$sSqlWrk = "SELECT `parent_id`, `parent_name` FROM `parent`";
		$sSqlWrk .= " ORDER BY `parent_order` Desc";
		$rswrk = $conn->Execute($sSqlWrk);
		$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
		if ($rswrk) $rswrk->Close();
		array_unshift($arwrk, array("", "Please Select"));
		$subcat->parent_id->EditValue = $arwrk;

		// sub_name
		$subcat->sub_name->EditCustomAttributes = "";
		$subcat->sub_name->EditValue = ew_HtmlEncode($subcat->sub_name->CurrentValue);

		// sub_order
		$subcat->sub_order->EditCustomAttributes = "";
		$subcat->sub_order->EditValue = ew_HtmlEncode($subcat->sub_order->CurrentValue);

		// sub_type
		$subcat->sub_type->EditCustomAttributes = "";
		$arwrk = array();
		$arwrk[] = array("1", "Intro");
		$arwrk[] = array("2", "List News");
		$arwrk[] = array("3", "Product HD");
		$arwrk[] = array("4", "Movie");
		$arwrk[] = array("5", "Product Dochoi");
		$subcat->sub_type->EditValue = $arwrk;

		// sub_link
		$subcat->sub_link->EditCustomAttributes = "";
		$subcat->sub_link->EditValue = $subcat->sub_link->CurrentValue;

		// sub_homepage
		$subcat->sub_homepage->EditCustomAttributes = "";
		$arwrk = array();
		$arwrk[] = array("1", "Home Page");
		$subcat->sub_homepage->EditValue = $arwrk;

		// sub_active
		$subcat->sub_active->EditCustomAttributes = "";
		$arwrk = array();
		$arwrk[] = array("1", "Active");
		$subcat->sub_active->EditValue = $arwrk;
	} elseif ($subcat->RowType == EW_ROWTYPE_SEARCH) { // Search row
	}

	// Call Row Rendered event
	$subcat->Row_Rendered();
}
?>
<?php

// Update record based on key values
function EditRow() {
	global $conn, $Security, $subcat;
	$sFilter = $subcat->SqlKeyFilter();
	if (!is_numeric($subcat->sub_id->CurrentValue)) {
		return FALSE;
	}
	$sFilter = str_replace("@sub_id@", ew_AdjustSql($subcat->sub_id->CurrentValue), $sFilter); // Replace key value
	$subcat->CurrentFilter = $sFilter;
	$sSql = $subcat->SQL();
	$conn->raiseErrorFn = 'ew_ErrorFn';
	$rs = $conn->Execute($sSql);
	$conn->raiseErrorFn = '';
	if ($rs === FALSE)
		return FALSE;
	if ($rs->EOF) {
		$EditRow = FALSE; // Update Failed
	} else {

		// Save old values
		$rsold =& $rs->fields;
		$rsnew = array();

		// Field sub_id
		// Field parent_id

		$subcat->parent_id->SetDbValueDef($subcat->parent_id->CurrentValue, 0);
		$rsnew['parent_id'] =& $subcat->parent_id->DbValue;

		// Field sub_name
		$subcat->sub_name->SetDbValueDef($subcat->sub_name->CurrentValue, NULL);
		$rsnew['sub_name'] =& $subcat->sub_name->DbValue;

		// Field sub_order
		$subcat->sub_order->SetDbValueDef($subcat->sub_order->CurrentValue, 0);
		$rsnew['sub_order'] =& $subcat->sub_order->DbValue;

		// Field sub_type
		$subcat->sub_type->SetDbValueDef($subcat->sub_type->CurrentValue, 0);
		$rsnew['sub_type'] =& $subcat->sub_type->DbValue;

		// Field sub_link
		$subcat->sub_link->Upload->SaveToSession(); // Save file value to Session
		if ($subcat->sub_link->Upload->Action == "2" || $subcat->sub_link->Upload->Action == "3") { // Update/Remove
		$subcat->sub_link->DbValue = $rs->fields('sub_link'); // Get original value
		if (is_null($subcat->sub_link->Upload->Value)) {
			$subcat->sub_link->Upload->DbValue = NULL;
		} else {
			$subcat->sub_link->Upload->DbValue = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, EW_UPLOAD_DEST_PATH), $subcat->sub_link->Upload->FileName);
		}
		$rsnew['sub_link'] =& $subcat->sub_link->Upload->DbValue;
		}

		// Field sub_homepage
		$subcat->sub_homepage->SetDbValueDef($subcat->sub_homepage->CurrentValue, NULL);
		$rsnew['sub_homepage'] =& $subcat->sub_homepage->DbValue;

		// Field sub_active
		$subcat->sub_active->SetDbValueDef($subcat->sub_active->CurrentValue, NULL);
		$rsnew['sub_active'] =& $subcat->sub_active->DbValue;

		// Call Row Updating event
		$bUpdateRow = $subcat->Row_Updating($rsold, $rsnew);
		if ($bUpdateRow) {

		// Field sub_link
			if (!is_null($subcat->sub_link->Upload->Value)) ew_SaveFile(ew_UploadPathEx(TRUE, EW_UPLOAD_DEST_PATH), $rsnew['sub_link'], $subcat->sub_link->Upload->Value);
			$conn->raiseErrorFn = 'ew_ErrorFn';
			$EditRow = $conn->Execute($subcat->UpdateSQL($rsnew));
			$conn->raiseErrorFn = '';
		} else {
			if ($subcat->CancelMessage <> "") {
				$_SESSION[EW_SESSION_MESSAGE] = $subcat->CancelMessage;
				$subcat->CancelMessage = "";
			} else {
				$_SESSION[EW_SESSION_MESSAGE] = "Update cancelled";
			}
			$EditRow = FALSE;
		}
	}

	// Call Row Updated event
	if ($EditRow) {
		$subcat->Row_Updated($rsold, $rsnew);
	}
	$rs->Close();

	// Field sub_link
	$subcat->sub_link->Upload->RemoveFromSession(); // Remove file value from Session
	return $EditRow;
}
?>
<?php

// Page Load event
function Page_Load() {

	//echo "Page Load";
}

// Page Unload event
function Page_Unload() {

	//echo "Page Unload";
}
?>
